package com.sakiko.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("jsp")
//@ResponseBody 不能添加
public class JspController {

    /**
     * 返回视图:
     * 1、导入依赖 jsp
     * 2、配置视图解析器
     * 3、定义 handler [注意不要@ResponseBody] 返回值类型为 String
     */
    @GetMapping("home")
    public String index(HttpServletRequest request) {
        System.out.println("JspController.index");
        request.setAttribute("name", "sakiko");
        return "index";
    }

    @GetMapping("login")
    public String jumpLogin() {
        System.out.println("JspController.jumpLogin");
        return "user/login";
    }
}
